package net.togogo.egouweb1238.core.service.area.impl;

import java.util.List;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import net.togogo.egouweb1238.common.page.Pagination;
import net.togogo.egouweb1238.core.dao.area.CityDao;
import net.togogo.egouweb1238.core.domain.area.City;
import net.togogo.egouweb1238.core.query.area.CityQuery;
import net.togogo.egouweb1238.core.service.area.ICityService;
/**
 * 市
 * @author stone
 */
@Service
@Transactional
public class CityServiceImpl implements ICityService {

	@Resource
	private CityDao cityDao;

	/**
	 * 插入数据库
	 * 
	 * @return
	 */
	public Integer addCity(City city) {
		return cityDao.addCity(city);
	}

	/**
	 * 根据主键查找
	 */
	@Transactional(readOnly = true)
	public City getCityById(Integer id) {
		return cityDao.getCityById(id);
	}
	
	@Transactional(readOnly = true)
	public List<City> getCitysByIds(List<Integer> idList) {
		return cityDao.getCitysByIds(idList);
	}

	/**
	 * 根据主键删除
	 * 
	 * @return
	 */
	public Integer deleteById(Integer id) {
		return cityDao.deleteById(id);
	}

	public Integer deleteByIds(List<Integer> idList) {
		return cityDao.deleteByIds(idList);
	}

	/**
	 * 根据主键更新
	 * 
	 * @return
	 */
	public Integer updateCityById(City city) {
		return cityDao.updateCityById(city);
	}
	
	@Transactional(readOnly = true)
	public Pagination getCityListWithPage(CityQuery cityQuery) {
		Pagination p = new Pagination(cityQuery.getPageNo(),cityQuery.getPageSize(),cityDao.getCityListCount(cityQuery));
		p.setList(cityDao.getCityListWithPage(cityQuery));
		return p;
	}
	
	@Transactional(readOnly = true)
	public List<City> getCityList(CityQuery cityQuery) {
		return cityDao.getCityList(cityQuery);
	}
}
